<template>
    <div class="itemMain">
        <div class="itemTit"><span>我的照片</span> <span class="reupload" @click="reupload" v-if="imgSrc!==''">重新上传</span></div>
        <div class="itemCont">
            <UploadImg @upload="uploadImg($event)" ref="upload" :imgSrc="imgSrc"></UploadImg>
        </div>
    </div>
</template>

<script>
import {axPost} from '@/api/index'
export default {
    data(){
        return{
            imgSrc:'',
            school:localStorage.getItem('school'),
            userid:localStorage.getItem('userid'),
            classCode:localStorage.getItem('classCode'),  
            // imgState:0
        }
    },
    // props:['ModuleData'],
    // mounted(){
    //     this.$nextTick(()=>{
    //         console.log('thi',this.ModuleData)
    //         if(this.ModuleData){

    //         }
    //     })
      
    // },
    methods:{
        submit(type){
           let state = 0
           if(this.imgSrc != ''){
               state = 1
           }
           if(type === 'myphoto'){
                const imageinfo = {
                    ImgUrl:this.imgSrc,
                    ImgState:state
                }
               axPost('ChangQingAddOrUpdateGrowRecord',{
                   school:this.school,
                   userid:this.userid,
                   imginfo:imageinfo
               }).then((res)=>{
                 console.log('---------------',res)
                   if(res.ResultCode == 1){
                      sessionStorage.getItem('hasChange1') &&  sessionStorage.removeItem('hasChange1')
                       this.$Tips({
                            content:'提交成功',
                            icon:'correct'
                        })
                        this.$emit('update')
                   }
               })
           }
        },
        reupload(){
            // this.$refs.upload.upload()
            this.$refs.upload.uploadImg1()
        },
         // 提交图片
        uploadImg(event){
           console.log(event)
           sessionStorage.setItem('hasChange1',true)
           this.imgSrc = event
        },
    }
}
</script>

<style lang='scss' scoped>
.itemMain{
    width: 100%;
    height: 100%;
    padding: .3rem;
    overflow: auto;
    .itemTit{
        width: 100%;
        font-size: .32rem;
        color: #262727;
        font-weight: bold;
        .reupload{
            font-size: .28rem;
            color: #168DFF;
            font-weight: normal;
        }
    }
    .itemCont{
        padding: .2rem 0;
    }
    
}
</style>